package cn.lijiancn01.demo;

import cn.hutool.db.meta.MetaUtil;
import cn.hutool.db.meta.Table;
import cn.hutool.json.JSONUtil;
import cn.lijiancn01.demo.system.codegen.JavaProperty;
import com.zaxxer.hikari.HikariDataSource;

public class MetaUtilTest {
    public static void main(String[] args) {
        //配置数据源
        HikariDataSource dataSource = new HikariDataSource();
        dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/amis?characterEncoding=utf-8");
        dataSource.setUsername("root");
        dataSource.setPassword("123456");

        Table table = MetaUtil.getTableMeta(dataSource, "demo");
        table.getColumns().forEach(c -> {
            Class<?> propertyTypeClz = JavaProperty.getPropertyTypeClz(c.getTypeEnum());
            System.out.println("private %s %s;".formatted(propertyTypeClz.getSimpleName(), c.getName()));
        });
    }
}
